<template>
	
	<view>
		<u-tabs :is-scroll="false" :list="slist"  active-color="rgb(250, 53, 52)" :current="current" @change="change"></u-tabs>
		<u-line></u-line>
		<view class="content">
			<block v-for="(item,index) in list" :key="index" >
				<mytie :item="item" @updatedata="updatedata"></mytie>
			</block>
		</view>
		
		<u-loadmore v-if="!nodata" :load-text="loadText" :status="status" icon-type="flower" margin-top="20"
			margin-bottom="20" />
			
			 <u-empty text=" 暂无数据" mode="list" v-if="nodata"></u-empty>
			 <auth :isauth="check_auth"></auth>
	</view>
	
	
</template>

<script>
	export default {
		data() {
			return {
			
				tie_status:0,
				slist: [{
					name: '全部'
				},{
					name: '待审核'
				}, {
					name: '审核通过'
				}, {
					name: '审核未通过'}

				],
				status: 'loadmore',
				page: 1,
				nodata: false,
				loadText: {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '实在没有了'
				},
				pageshow: false,
				list: [],
				current: 0
				
			}
		},
		
		async onLoad(e){
			if (e.status){
				this.tie_status=e.status
				this.current=e.status
			}
			
			//#ifdef H5
			  if (!uni.getStorageSync("user")){
				  alert(2222)
				  let a=await this.openid()
				  this.user=uni.getStorageSync("user");
			  }    
			//#endif
			   
			 this.item_list()
		},
		onReachBottom() {
			if (this.status != 'loadmore') {
				return;
			}
			this.status = "loading"
			this.page++;
			this.item_list()
		},
		methods: {
		updatedata(){
			this.item_list()
		},
          change(index){
			  this.nodata=false;
			  this.current = index;
			  this.tie_status=index
			  this.status = "loading"
			  this.page=1;
			  this.item_list()
		  }, 
		  item_list() {
			 
		  	this.$u.post('index.php?mod=app&act=list&table=tie&jian=1', {
		  		    limit: 6,
				    userht:1,
					uid:uni.getStorageSync("uid"),
					status:this.tie_status,
		  		page: this.page
		  	}).then(res => {
		  		this.pageshow = true
		  		this.active = false
		  		let total = res.count
		  		this.count = res.count
		  		if (this.page == 1)
		  			this.list = res.data
		  		else
		  			this.list = this.list.concat(res.data)
		        
		  		if (total == this.list.length) {
		  
		  			if (this.list.length == 0) {
		  				this.nodata = true
		  			} else
		  				this.status = "nomore"
		  			//this.loadText.nomore = (this.total > res.pagesize) ? "实在没有了" : ""
		  		} else {
		  			this.status = "loadmore"
		  		}
		  
		  	});
		  },
		}
	}
</script>

<style>
	.content{margin: 10rpx auto;}
</style>
